<?php 
if($mode== "ADD"){

	?>
<script
	type="text/javascript"
	src="<?= base_url();?>third_party/fancy_box/lib/jquery-1.8.0.min.js"></script>
<link
	rel="stylesheet" type="text/css" media="all"
	href="<?= base_url();?>third_party/jsdatepick-calendar/jsDatePick_ltr.min.css" />
<script
	type="text/javascript"
	src="<?= base_url();?>third_party/jsdatepick-calendar/jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
	window.onload = function(){
		new JsDatePick({
			useMode:2,
			target:"startDate",
			dateFormat:"%d-%m-%Y"			
		});
		new JsDatePick({
			useMode:2,
			target:"endDate",
			dateFormat:"%d-%m-%Y"			
		});
	};
</script>

<section class="wrapper">
	<div class="col-lg-12">
		<!--work progress start-->
		<section class="panel">

			<div class="inbox-head">
				<h3>BANNER MANAGEMENT (ADD)</h3>
			</div>
			<div class="panel-body">
				<form class="form-horizontal" role="form" method="POST"
					enctype="multipart/form-data"
					action="<?= base_url(); ?>banner/admin/banner/upload_banner">
					<input type="hidden"
						name="<?php echo $this->security->get_csrf_token_name(); ?>"
						value="<?php echo $this->security->get_csrf_hash();?>" />
					<?php
					$this->session->flashdata('message'); {
						$msg = $this->session->flashdata('message');
						echo '<font color="red">' . $msg . '</font>';
					}
					?>
					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Select Size</label>
						<div class="col-lg-2">
							<select class="form-control" name="banner_size">
								<option selected="selected" value="">---Select Size---</option>
								<?php foreach ($pickup['banner_size'] as $banner_size): ?>
								<option value="<?= $banner_size->description; ?>">
									<?= $banner_size->description; ?>
								</option>
								<?php endforeach; ?>
							</select>

						</div>
						<div class="col-lg-4">

							<input type="file" name="userfile" value="Browse" /> <input
								type="hidden" name="id">

						</div>
						<!-- <span class="text text-warning"><b>(IMAGE SIZE : WIDTH X HEIGHT<br>
								FRONT SLIDER IMAGE : 724 X 200)</b></span> -->
					</div>
					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Banner title</label>
						<div class="col-lg-6">
							<input type="text" class="form-control" name="banner_title"
								id="banner_title" placeholder="Banner Title">
						</div>
					</div>

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Link</label>
						<div class="col-lg-6">
							<input type="text" class="form-control" name="link" id="link"
								placeholder="Banner Link">
						</div>
					</div>

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Start date</label>
						<div class="col-lg-3">
							<input type="text" class="form-control" name="start_date"
								id=startDate placeholder="Start Date">
						</div>
					</div>

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">End date</label>
						<div class="col-lg-3">
							<input type="text" class="form-control" name="end_date"
								id="endDate" placeholder="End Date">
						</div>
					</div>

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Max impressions</label>
						<div class="col-lg-1">
							<input type="text" class="form-control" name="impression"
								id="impression" placeholder="Max Impressions">
						</div>
						<span class="text text-warning"><b>( 0 = UNLIMITED )</b> </span>
					</div>

					<!-- <div class="form-group">
					<label for="input" class="col-lg-2 control-label">Max clicks</label>
					<div class="col-lg-1">
						<input type="text" class="form-control" name="click" 
							id="click" placeholder="Max Clicks">
					</div>
					<span class="text text-warning"><b>( 0 = UNLIMITED )</b></span>
				</div> -->

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Show</label>
						<div class="col-lg-2">
							<select class="form-control" name="show">
								<option selected="selected" value="">---Select Pgae---</option>
								<option value="0">All</option>
								<option value="1">Index Page</option>
								<option value="2">Inner Page</option>
								<option value="3">
									Category
									</opyion>
								
								<option value="4">Slider</option>
							</select> </select>
						</div>
						<span class="text text-warning"><b>( ASSIGN PAGE )</b> </span>
					</div>



					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Select Category</label>
						<div class="col-lg-4">
							 <select class="form-control selectpicker"
								name="category">
								<option value="" selected="selected">-------Select Category-------</option>
								<?php 
							if($parent){
								foreach ($parent as $category):?>
								<optgroup label="Parent">
								

							<?php 
							$subCategory = $this->category_model->getChild($category->id,10,FALSE);
							//print_r($subCat); die();
							?>
								
									
								<option value="<?= $category->id;?>">
									<?= $category->name;?>
								</option>
								
								</optgroup>
								
								<optgroup label="Child">
								<?php 
									if($subCategory){
											foreach ($subCategory as $subCat):?>
								<option value="<?= $subCat->id;?>">
									<?= $subCat->name;?>
								</option>
								<?php endforeach;
									}
									?>
								</optgroup>
								
									<?php endforeach;
							}
							?>
							</select>
						</div>
						<span class="text text-warning"><b>( ASSIGN CATEGORY )</b> </span>

					</div>

					<div class="form-group">
						<div class="col-lg-offset-2 col-lg-10">
							<input type="submit" name="upload" class="btn btn-warning"
								value="Add Now" <?php if($this->config->item('mode')=='DEMO'){?>
								onclick="alert ('Sorry! Not allowed in demo mode '); return false;"
					<?} else?> onclick="return confirm('Are you sure ?');">
						</div>
					</div>
				</form>
			</div>
			<!-- End of Body Panel -->
		</section>
	</div>
	<!-- page end-->
</section>
<?php }?>
<?php 
if($mode=="EDIT"){
	?>

<script
	type="text/javascript"
	src="<?= base_url();?>third_party/fancy_box/lib/jquery-1.8.0.min.js"></script>
<link
	rel="stylesheet" type="text/css" media="all"
	href="<?= base_url();?>third_party/jsdatepick-calendar/jsDatePick_ltr.min.css" />
<script
	type="text/javascript"
	src="<?= base_url();?>third_party/jsdatepick-calendar/jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
	window.onload = function(){
		new JsDatePick({
			useMode:2,
			target:"startDate",
			dateFormat:"%d-%m-%Y"			
		});
		new JsDatePick({
			useMode:2,
			target:"endDate",
			dateFormat:"%d-%m-%Y"			
		});
	};
</script>

<section class="wrapper">
	<div class="col-lg-12">
		<!--work progress start-->
		<section class="panel">

			<div class="inbox-head">
				<h3>BANNER MANAGEMENT (EDIT)</h3>
			</div>
			<div class="panel-body">
				<form class="form-horizontal" name="banner" role="form"
					method="POST" enctype="multipart/form-data"
					action="<?= base_url(); ?>banner/admin/banner/update_banner">
					<input type="hidden"
						name="<?php echo $this->security->get_csrf_token_name(); ?>"
						value="<?php echo $this->security->get_csrf_hash();?>" />
					<?php
					$this->session->flashdata('message'); {
						$msg = $this->session->flashdata('message');
						echo '<font color="red">' . $msg . '</font>';
					}
					?>
					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Select Size</label>
						<div class="col-lg-2">
							<select class="form-control" name="banner_size">
								<option value="" selected="selected">---Select Size---</option>

								<?php foreach($banner_size as $banner_size):?>
								<option value="<?= $banner_size->description; ?>"
								<?php if($banner_size->description == $banners['details']->size){echo "selected=selected";}?>>
									<?= $banner_size->description; ?>
								</option>
								<?php endforeach; ?>
							</select>

						</div>
						<div class="col-lg-4">

							<input type="file" name="userfile"
								value="<?= $banners['details']->value;?>">

						</div>
						<img height="50" width="80"
							src="<?= base_url();?>assets/img/advertisement/<?= $banners['details']->value;?>"
							alt="Image 001" />

					</div>
					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Banner title</label>
						<div class="col-lg-6">
							<input type="text" class="form-control" name="banner_title"
								value="<?= $banners['details']->title;?>"
								placeholder="Banner Title">
						</div>
					</div>

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Link</label>
						<div class="col-lg-6">
							<input type="text" class="form-control" name="link"
								value="<?= $banners['details']->url;?>"
								placeholder="Banner Link">
						</div>
					</div>

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Start date</label>
						<div class="col-lg-3">
							<input type="text" class="form-control" name="start_date"
								id=startDate value="<?= $banners['details']->start_date;?>">
						</div>
					</div>

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">End date</label>
						<div class="col-lg-3">
							<input type="text" class="form-control" name="end_date"
								id="endDate" value="<?= $banners['details']->end_date;?>">
						</div>
					</div>

					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Max impressions</label>
						<div class="col-lg-1">
							<input type="text" class="form-control" name="impression"
								id="impression"
								value="<?= $banners['details']->max_impressions;?>">
						</div>
						<span class="text text-warning"><b>( 0 = UNLIMITED )</b> </span>
					</div>
					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Show</label>
						<div class="col-lg-2">
							<select class="form-control" name="show">
								<option value="0"
								<?php if ($banners['details']->shows=="0") echo 'selected="selected"';?>>All</option>

								<option value="1"
								<?php if ($banners['details']->shows=="1") echo 'selected="selected"';?>>Index
									Page</option>
								<option value="2"
								<?php if ($banners['details']->shows=="2") echo 'selected="selected"';?>>Inner
									Page</option>

								<option value="3"
								<?php if ($banners['details']->shows=="3") echo 'selected="selected"';?>>Category</option>

								<option value="4"
								<?php if ($banners['details']->shows=="4") echo 'selected="selected"';?>>Front
									Slider</option>

							</select> </select>
						</div>
						<span class="text text-warning"><b>( ASSIGN PAGE )</b> </span>
					</div>



					<div class="form-group">
						<label for="input" class="col-lg-2 control-label">Select Category</label>
						<div class="col-lg-4">
						<select class="form-control selectpicker"
								name="category">
								<option value="" selected="selected">-- -- -- -- --Select Category-- -- -- -- -- --</option>
								<?php 
							if($parent){
								foreach ($parent as $category):?>
								<optgroup label="Parent">
								

							<?php 
							$subCategory = $this->category_model->getChild($category->id,10,FALSE);
							//print_r($subCat); die();
							?>
								
									
								<option value="<?= $category->id;?>"
								<?php if($category->id == $banners['details']->cat_id){echo "selected=selected";}?>>
									<?= $category->name;?>
								</option>
								
								</optgroup>
								
								<optgroup label="Child">
								<?php 
									if($subCategory){
											foreach ($subCategory as $subCat):?>
								<option value="<?= $subCat->id;?>"
								<?php if($subCat->id == $banners['details']->cat_id){echo "selected=selected";}?>>
									<?= $subCat->name;?>
								</option>
								<?php endforeach;
									}
									?>
								</optgroup>
								
									<?php endforeach;
							}
							?>
							</select>
							
						</div>
						<span class="text text-warning"><b>( ASSIGN CATEGORY )</b> </span>

					</div>

					<div class="form-group">
						<div class="col-lg-offset-2 col-lg-10">
							<input type="hidden" name="id" value="<?= $id;?>"> <input
								type="submit" class="btn btn-info" name="upload" value="Update"
								<?php if($this->config->item('mode')=='DEMO'){?>
								onclick="alert ('Sorry! Not allowed in demo mode '); return false;"
								<?} else?> onclick="return confirm('Are you sure ?');" />

						</div>
					</div>
				</form>
			</div>
			<!-- End of Body Panel -->
		</section>
	</div>
	<!-- page end-->
</section>
<?php }?>



